package com.mago.tis.utility;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	public static String getFormattedDate(Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
		String formattedDate = null;
		java.sql.Date dateDB = null;
		try {
			formattedDate = formatter.format(date);
			System.out.println("Formatted Date : " + formattedDate);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return formattedDate;
	}

	public static Date convertStringToDate(String dateInString) {
		// Excel specific date format
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		//SimpleDateFormat formatter = new SimpleDateFormat("kk:mm:ss");
		Date date = null;
		try {
			date = formatter.parse(dateInString);
			System.out.println(date);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return date;
	}

	public static String getTime(Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
		String formattedDate = null;
		try {
			formattedDate = formatter.format(date);
			System.out.println("Formatted Date : " + formattedDate);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return formattedDate;
	}

	public static void main(String... s) {
		// getFormattedDate(new Date());
		// convertStringToDate("Mon May 27 11:46:15 IST 2013");
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
		try {
			String formattedDate = dateFormat.format(new Date());
			// Date date = dateFormat.parse("Sun Dec 31 00:03:07 IST 1899");
			// long time = date.getTime();
			System.out.println(formattedDate);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
